Repository navigation
Unmanaged gradient accumulation: ZeRO stage 3 support - #8217
Merged
Merged
Conversation
sfc-gh-truwase
requested review from
loadams,
tjruwase and
tohtana
as code owners
August 5, 2026 17:16
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25f5817973
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Allow managed_gradient_accumulation=False for ZeRO stage 3 (non-offload). Stage 3 partitions gradients into __param_id_to_grad_partition on every backward (as in managed mode); step() only marks the boundary via finalize_gradient_accumulation_boundary(). Since stage 3 is now permitted, also reject ZeRO parameter offload (previously unreachable). ZeRO offload (optimizer state and parameter) remains rejected pending the follow-up PR; pipeline parallelism, DeepCompile, and Apex AMP stay unsupported. Validated on a 2-GPU node (full -k Unmanaged suite, 29 passed) incl. test_unmanaged_matches_managed[3] and test_unmanaged_varying_backward_count[3]. Signed-off-by: Olatunji Ruwase <tunji.ruwase@snowflake.com> Co-authored-by: Cursor <cursoragent@cursor.com>
sfc-gh-truwase
force-pushed
the
sfc-gh-truwase/gas_mgmt_zero3
branch
from
August 5, 2026 18:34
25f5817 to
ea671a5
Compare
stas00
approved these changes
Aug 5, 2026
2 tasks done
banxingmjj
pushed a commit
to openanolis/DeepSpeed
that referenced
this pull request
Aug 9, 2026
## Summary * Extends unmanaged gradient accumulation (`managed_gradient_accumulation=false`) to **ZeRO optimizer-state and parameter offload** (CPU/NVMe). Follow-up to deepspeedai#8217 (ZeRO stage 3, now merged). * Stage 2/3: grads still reduce/partition every `backward()`; `step()` finalizes deferred offload boundary work (grad norms + FP32/NVMe copy) via `finalize_gradient_accumulation_boundary()`. * Stage 1: continues to reduce at `step()` via `allreduce_gradients()`, which already performs offload boundary finalization when the boundary flag is true. * Pipeline parallelism, DeepCompile, Apex AMP, and stage-0/1 `overlap_comm` remain unsupported. ## Test plan Validated on a 2-GPU node: * [x] Full `-k Unmanaged` suite (**31 passed**), including: * `test_unmanaged_matches_managed_optimizer_offload[1|2|3]` * `test_unmanaged_matches_managed_param_offload` (stage 3) * existing non-offload unmanaged equivalence / varying-GAS / rejection tests * [x] Docs updated (`config-json.md`, `training.rst`); previewable on `rtd-staging` Made with [Cursor](https://cursor.com) --------- Signed-off-by: Olatunji Ruwase <tunji.ruwase@snowflake.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Ma, Guokai <guokai.ma@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
managed_gradient_accumulation=false) to ZeRO stage 3 (non-offload). Stacked follow-up to Unmanaged gradient accumulation: ZeRO stage 2 support #8203 (now merged).__param_id_to_grad_partitionon everybackward()(as in managed mode);step()only marks the boundary viafinalize_gradient_accumulation_boundary().Test plan
Validated on a 2-GPU node:
-k Unmanagedsuite (29 passed), includingtest_unmanaged_matches_managed[3]andtest_unmanaged_varying_backward_count[3]test_zero_grad_clip,test_zero_leaf_module,test_zero_context,test_zero_tensor_fragment): 158 passed, 62 skipped (expected)Docs (
config-json.md,training.rst) updated; previewable onrtd-staging.Made with Cursor